
export class PagedQueryResult<T>{
	/**
	 *满足条件的总数据条数
	*/
	recordCount: number;
	/**
	 * 满足条件的总页数
	*/
	pageCount: number;
	/**
	 * 当前页数据
	*/
	datas: T[];
}
export abstract class PagedQueryParam {
	/**
	 * 要查询第几页，从0开始
	*/
	pageNumber: number = 0;
	/** 
	 * 每页数据条数，缺省20
	 * */
	pageSize: number = 20;
	/**
	*排序，分号分隔每一组条件，组内用冒号分隔。
	*属性引用，如: seq:ASC; userCode:DESC 表示 seq升序，然后userCode降序
	*支持SQL条件，如：SQL:abs(VALUE_DIFF):ASC; SQL:decode(checked_summary,0,1,abs(VALUE_DIFF/checked_summary)):DESC
	*/
	orderBy: string;

	changePage(event: DataEvent): void {
	    if (!event) {
	        this.pageNumber = 0;
	        return;
	    }
		if (event.page !== undefined) {
			this.pageNumber = event.page;
		} else {
			this.pageNumber = event.first / this.pageSize;
		}
		if (event.sortField) {
			this.orderBy = event.sortField;
			if (event.sortOrder == -1) {
				this.orderBy += ":ASC";
			} else {
				this.orderBy += ":DESC";
			}
		}
		if (event.multiSortMeta) {
			for (let sm of event.multiSortMeta) {
				if (this.orderBy) {
					this.orderBy += "; ";
				}
				this.orderBy = event.sortField;
				if (event.sortOrder == -1) {
					this.orderBy += ":ASC";
				} else {
					this.orderBy += ":DESC";
				}

			}
		}
	}
}
/**
 * primeng Table Paginator的事件数据结构
 */
export class DataEvent {

	/**
	 * Index of the first record
	 */
	first: number;
	/**
	 * Number of rows to display in new page
	 */
	rows: number;
	/**
	 * Index of the new page
	 */
	page: number;
	/**
	 * Total number of pages
	 */
	pageCount: number;
	/**
	 * Field name to sort in single sort mode
	 */
	sortField: string;
	/**
	 * Sort order as number, 1 for asc and -1 for dec in single sort mode
	 */
	sortOrder: number;
	/**
	 * An array of SortMeta objects used in multiple columns sorting. Each SortMeta has field and order properties.
	 */
	multiSortMeta: SortMeta[];
	//filters: Filters object having field as key and filter value, filter matchMode as value
	//globalFilter: Value of the global filter if available
}
export class SortMeta {
	/**
	 * Field name to sort in single sort mode
	 */
	sortField: string;
	/**
	 * Sort order as number, 1 for asc and -1 for dec in single sort mode
	 */
	sortOrder: number;
}
export class Selectable {
	isSelected: boolean;
}
export class RefBean extends Selectable {
	code: string;
	name: string;
	constructor(code: string, name: string) {
		super();
		this.code = code;
		this.name = name;
	}
}
export class RefBeanTreeNode extends RefBean {
	children: RefBeanTreeNode[];
}
export class RestResult {
	status: string;
	value: any;
}
